<template>
  <div class="container">
    <Headbar />
    <HeadMenu />
    <Hungbar />
    <div class="market-list-content">
        <div class="market-list-wrap">
          <div class="market-con" v-for="item in marketList">
            <a :href="URL.mall+'/market/major?marketId='+item.marketId" target="_blank">
            <div class="market-logo">
                <img :src="URL.PIC+item.logo" />
            </div>
            <div class="market-details">
                <h3 class="market-company">
                    <span class="market-greet">{{item.marketName}}</span>
                </h3>
                <div class="market-label">
                    <span class="classify-label" v-for="tag in item.marketTags">{{tag}}</span>
                </div>
                <p class="parking-fee market-msg">
                    <span class="common-left-con">停车费用</span>：
                    <span class="common-right-con" v-if="item.marketIntro!=undefined">{{item.marketIntro.parkCost}}</span>
                </p>
                <p class="opening-hours market-msg">
                    <span class="common-left-con">营业时间</span>：
                    <span class="common-right-con" v-if="item.marketIntro!=undefined">{{item.marketIntro.officeTime}}</span>
                </p>
                <p class="market-address market-msg">
                    <span class="common-left-con">地址</span>：
                    <span class="common-right-con" v-if="item.marketIntro!=undefined" :title="item.marketIntro.address">{{item.marketIntro.address}}</span>
                </p>
            </div>
            <div class="market-products">
              <div class="market-pd-box cursor" v-for="(factory,index) in item.factorys" v-if="index<4">
                <div class="market-pd-per">
                  <a :href="URL.mall+'/factory/'+ factory.factoryId" target="_blank">
                    <img :src="URL.PIC+(factory.logo==null?'/pic/user/avatar/avatar.png':factory.logo)" width="140" height="140">
                  </a>
                  <P class="market-pd-company">{{factory.factoryName}}</P>
                </div>
              </div>
              <!-- <div class="shop-right-share">
                <img src="../../assets/images/search/search_12.png"/>
              </div>
              <div class="shop-right-share">
                <img src="../../assets/images/search/search_13.png"/>
              </div>
              <div class="shop-Qr-code">
                <img class="qr-img" src="../../assets/images/merchants/pub-ico39.png"/>
                <p class="qr-tips">扫一扫，进入手机旺铺</p>
              </div> -->
            </div>
            </a>
          </div>
          <Pagination v-show="total>0" :total="total" layout="prev, pager, next, total, jumper" :page.sync="listQuery.page" :limit.sync="listQuery.size"
                        @pagination="getMarketHotList"/>
        </div>
    </div>
    <Footbars /> 
  </div>
</template>

<script>
import Headbar from '@/components/Layouts/Headbar'
import HeadMenu from '@/components/Layouts/HeadMenu'
import Hungbar from '@/components/Layouts/Hungbar'
import Footbars from '@/components/Layouts/Footbars'
import Pagination from '@/components/Pagination'

import {getMarketList,getMarketDetail,factoryRecommend} from '@/api/market'
export default {
  name: 'List',
  components: {
    Headbar,
    HeadMenu,
    Hungbar,
    Footbars,
    Pagination
  },
  data() {
    return {
        marketList:[],
        listQuery:{
            page:1,
            size:25
        },
        total:0,
    }
  },
  created() {
      this.getMarketHotList();
  },
  methods: {
      //精选市场
      getMarketHotList(){
          this.marketList = [];
          let params = {
              'pageable.page':this.listQuery.page,
              'pageable.size':this.listQuery.size,
          }
          getMarketList(params).then(res=>{
              this.marketList = res.data.list;
              this.total = res.data.pageCount;
              this.marketList.forEach((item,index)=>{
                  getMarketDetail({marketId:item.marketId}).then(res=>{
                      item['marketIntro'] = res.data;
                  });
                  // factoryRecommend({marketId:item.marketId}).then(res=>{
                  //     item['factorys'] = res.data.list;
                  // });
              });
          });
      },
  }
}
</script>

<style lang="scss" scoped>
@import '@/styles/pages/market.scss';
</style>
